from flask import Flask, flash, redirect, render_template, request, url_for

'''
消息闪现
'''
app = Flask(__name__)
# 设置秘钥
app.secret_key = b'\xa8yVs0\x8e\xe6\x03\x9fFp\x1d\xd9\xda\xb3\x00'

@app.route('/')
def index():
    return render_template('index.html')

@app.route('/login', methods=['GET', 'POST'])
def login():
    error = None
    if request.method == 'POST':
        if request.form['username'] != 'admin' or request.form['password'] != 'secret':
            error = flash('Invaild credentials', 'error')
        else:
            flash('You were successfully logged in')
            return redirect(url_for("index"))
    return render_template('login.html', error=error)
            
if __name__ == "__main__":
    app.run()